<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body style="font-family:Arial;">
<h1>Shop RMA Submit Order List  <?php echo $_POST['date_begin'] ?>  to <?php echo $_POST['date_end'] ?> </h1>
<?php 
//var_dump($this->topnum);
//var_dump($this->fproducts);
$counter = 0;
$topnum = 999;

$w4DateBegin =  new DateTime(date("Y-m-d",strtotime(trim($_POST['date_begin']))));
date_sub($w4DateBegin ,date_interval_create_from_date_string('28 days'));
$w4Begin = date_format($w4DateBegin ,'Y-m-d');

$w4DateEnd =  new DateTime(date("Y-m-d",strtotime(trim($_POST['date_end']))));
date_sub($w4DateEnd ,date_interval_create_from_date_string('28 days'));
$w4End = date_format($w4DateEnd ,'Y-m-d');

?>
<table width="888" border="0" cellspacing="1" cellpadding="5" bgcolor="#666666">
  <tr>
    <td bgcolor="#FFFFFF">Shop Code</td>
    <td bgcolor="#FFFFFF">PCs</td>
    <td bgcolor="#FFFFFF">-4 Weeks Pcs (<?php echo $w4Begin." to ".$w4End; ?>)</td>
  </tr>
<?php 
$fProduct = new Model_DbTable_Faultyproduct();



foreach($this->fproducts as $key => $value){
if($counter < $topnum){
	$w4TopShop = $fProduct->sumFaultySingleShopByDate($value['shopcode_faulty'],$w4Begin, $w4End);
?>  
  <tr>
    <td bgcolor="#FFFFFF">
	<a href="/faultyaudit/faultyshopdetail?shop_code=<?php echo $value['shopcode_faulty']?>&date_begin=<?php echo $_POST['date_begin']?>&date_end=<?php echo $_POST['date_end']?>" title="<?php echo $pTitle; ?>" >
	<?php echo $value['shopcode_faulty']?>
    </a>
    </td>
    <td bgcolor="#FFFFFF"><?php echo $value["SUM(`faulty_qty`)"]?></td>
    <td bgcolor="#FFFFFF"><?php echo $w4TopShop[0]["SUM(`faulty_qty`)"]?></td>
  </tr>
<?php
	}
$counter++;	
}
?>  
  
  <tr>
    <td bgcolor="#FFFFFF">Shop Code</td>
    <td bgcolor="#FFFFFF">PCs</td>
    <td bgcolor="#FFFFFF">-4 Weeks Pcs</td>
  </tr>
</table>

</body>
</html>
